#include "stm32f10x.h"
#include "adt_usart.h"
#include "adt_led.h"
#include "adt_sch.h"
#include "adt_key.h"
LED led4,led5,led6,led7;
SCH TaskLed;
void led_init(void)
{
	 led4 = LED_New(GPIOC,GPIO_Pin_7);
	 led5 = LED_New(GPIOC,GPIO_Pin_8);
	 led6 = LED_New(GPIOA,GPIO_Pin_12);
	 led7 = LED_New(GPIOC,GPIO_Pin_10);
}

void led_flash(void *para)
{
	static int i;
	i = 1 - i;
	if(i){
		LED_Set(led7,LED_ON);
	}else{
		LED_Set(led7,LED_OFF);
	}
}
void Key1_Handle(void)
{
	static int i;
	i = 1- i;
	if(i){
		SCH_TaskControl(TaskLed,true);
	}else{
		SCH_TaskControl(TaskLed,false);
	}
}
int main(void)
{	
	SCH_Init();
	led_init();
	KEY_Init();

	TaskLed = SCH_AddTask(led_flash,(void *)led7,0,500,12,LOOP_Enum);
	KEY_Add(GPIOC,GPIO_Pin_11,ClickDownMode,Key1_Handle);
	
	while(1)
	{
		SCH_Dispatch_Tasks();
		KEY_Run();
	}
}

